﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Castle.RegistrationSubjects.Data;
using Castle.Utilities;
using System.Text;
namespace Castle.RegistrationSubjects.interfaces
{
    public partial class _5b4ed8e7_9e2e_4ac3_bb78_517f2ef3216e : System.Web.UI.Page
    {
        #region Members
        private string dotDKUID
        {
            set { hid_dotDKUID.Value = value; }
            get { return hid_dotDKUID.Value; }
        }
        DataTable dtWrite = new DataTable();
        #endregion
        #region Variable
        string err = "";
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["DotUID"] != null)
                {
                    if (!Page.IsPostBack)
                    {
                        string nb = EncryptionNoneKey.Decrypt(Request.QueryString["DotUID"].ToString());
                        if (string.IsNullOrEmpty(nb))
                        {
                            Response.Redirect("/app/dkmh/danh-sach-cac-dot-dang-ky-mon-hoc");
                        }
                        dotDKUID = nb;
                        /**********************Tên đợt đăng ký***************************************/
                        lbTitle.Text = SessionInfo.GetInfoDotDK(dotDKUID).DotDKID;
                        /***********************AAO Url************************************************/
                        LoadNoiDungEmail();
                    }
                }
                else
                {
                    
                }
            }
            catch
            {
                
            }
        }

        #region Load nội dung email
        public void LoadNoiDungEmail()
        {
            try
            {
                IsubLogMailXacNhanKQ Isub = new subLogMailXacNhanKQ();
                DataTable dt = Isub.sub_GetListsubLogMailXacNhanKQByHocVien(dotDKUID, SessionInfo.GetInfoHocVienLogined.HocVienUID, ref err);
                if (dt.Rows.Count > 0)
                {
                    lst_Log.DataSource = dt;
                    lst_Log.DataBind();
                }
                else
                {
                    Label lbl = new Label();
                    lbl.Text = "Không tìm thấy nhật ký đăng ký của bạn";
                    lbl.ForeColor = System.Drawing.Color.Red;
                    lbl.Font.Size = FontUnit.Large;
                    lbl.Font.Bold = true;
                    lbl.CssClass = "lbl_note_kqdk";
                    pnNoiDungMail.Controls.Add(lbl);
                }
                Isub = null;
                dt = null;
            }
            catch (Exception ex)
            {
                err = ex.Message;
            }
            Msg(err);
        }
        #endregion


        private void Msg(string msg)
        {
            if (string.IsNullOrEmpty(msg))
            {
                return;
            }
            StringBuilder sb = new StringBuilder();
            sb.Append("$.msgBox({title: 'Thông báo',content: '" + msg + "'});");
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "MSGBOXJQ", sb.ToString(), true);
        }

        protected void hpy_ViewLog_OnClick(object sender, EventArgs e)
        {
            LinkButton hpy_ViewLog = (LinkButton)sender;
            if (string.IsNullOrEmpty(hpy_ViewLog.CommandArgument))
            {
                return;
            }
            StringBuilder sb = new StringBuilder();
            sb.Append("<object type='text/html' data='/app/dkmh/xem-nhat-ky-dang-ky/" + EncryptionNoneKey.Encrypt(hpy_ViewLog.CommandArgument) + "' style='width:100%; height:500px; margin:1%;'></object>");
            view_log.InnerHtml = sb.ToString();
        }

        protected void btnReturn_Click(object sender, EventArgs e)
        {
            Response.Redirect("/app/dkmh/dang-ky-mon-hoc");
        }
    }
}